# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=forager
pkgver=v2.0.3.r3.g7439b0a
pkgrel=1
epoch=1
groups=('blackarch' 'blackarch-recon')
arch=('any')
pkgdesc='Multithreaded threat Intelligence gathering utilizing.'
url='https://github.com/byt3smith/Forager'
license=('MIT')
depends=('python' 'python-virtualenv')
makedepends=('git' 'python-pip')
source=("$pkgname::git+https://github.com/byt3smith/Forager.git")
sha512sums=('SKIP')
install="$pkgname.install"

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
source venv/bin/activate
exec python Forager.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

